<%@ page language="java" import="java.util.*" pageEncoding="utf-8"   isELIgnored="false"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib  prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
	<title>IT园欢迎您！</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta name="Keywords" content="">
	<meta name="description" content="">
	<link href="css/user.css" rel="stylesheet" type="text/css">
	<link rel="stylesheet" href="bootstrap-3.3.5-dist/dist/css/bootstrap.css" type="text/css"></link>
	<link href="css/upload-res.css" rel="stylesheet" type="text/css">
	<script src="js/jquery-1.10.2.min.js"></script>
	<script src="bootstrap-3.3.5-dist/dist/js/bootstrap.min.js"></script>
	<script src="js/user.js"></script>
  </head>
<body>
<%--账号管理页面 --%>
	<jsp:include page="/user/question/questionLeft.jsp"></jsp:include>
	<div style="float: left;width:980px;margin-top: 8px;margin-left: 30px;">
		<table class="table">
			  <thead>
			    <tr>
			      <th><input type="checkbox"></th>
			      			<th>问题回答</th>
							<th>点赞数</th>
							<th>是否采纳</th>
							<th>回答时间</th>
							<th>操作</th>
			      </tr>
			  </thead>
 			 <tbody>
  					<c:forEach items="${questionAnswers }" var="questionAnswer">
						<tr>
							<td><input type="checkbox"></td>
							<td>
								<c:choose> 
									     <c:when test="${fn:length(questionAnswer.questionAnswer) > 26}">${fn:substring(questionAnswer.questionAnswer, 0, 20)}......</c:when> 
									     <c:otherwise> ${questionAnswer.questionAnswer }</c:otherwise>
								</c:choose>
							</td>
							<td>${questionAnswer.questionThumbsup }</td>
							<td>${questionAnswer.iSAdopt==0?"未采纳":"已采纳" }</td>
							<td><fmt:formatDate value="${questionAnswer.createDate}" type="both" pattern="yyyy-MM-dd HH:mm:ss" /></td>
							<td>
								<a  class="btn btn-warning" href="user/question/deleteQuestionAnswer?questionAnswerId=${questionAnswer.id }&questionId=${questionAnswer.questionId}">删除</a>
								<c:if test="${questionAnswer.iSAdopt==0}">
									<a  class="btn btn-info" href="user/question/closeQuestion?questionId=${questionAnswer.id }">未采纳</a>
								</c:if>
								<c:if test="${questionAnswer.iSAdopt==1}">
									<a  class="btn btn-info" href="javascript:void(0);"  disabled="disabled" >已采纳</a>
								</c:if>
								<button class="btn btn-primary" data-toggle="modal" data-target="#myModal"  data-content="${questionAnswer.questionAnswer }">回答详情</button>
							</td>
						</tr>
				</c:forEach>
  			</tbody>
		</table>
	</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					回答详情
				</h4>
			</div>
			<div class="modal-body">
				<script>
				$(document).click(function(e) { // 在页面任意位置点击而触发此事件
  					var content= $(e.target).attr("data-content");       // e.target表示被点击的目标
  					$('.modal-body').html(content);
				})
		</script>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-info" data-dismiss="modal">关闭
				</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
</body>
</html>
